<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title>凯盛项目管理系统</title>
	<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />
	<link rel = "Shortcut Icon" href="http://www.kaishengit.com/favicon.ico" />
	<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
	<div class="container">
		<div class="navbar">
			<div class="navbar-inner">
				<div class="container">
					<a href="main" class="brand">凯盛项目管理系统</a>
					<ul class="nav pull-right">
						<li class="active">
							<a>${user.name }</a>
						</li>
						<li>
							<a href="user">个人资料</a>
						</li>
						<li class="divider-vertical"></li>
						<li>
							<a href="loginout">安全退出</a>
						</li>
					</ul>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="span3">
				<div class="wall">
					<ul class="nav nav-list">
						<li class="nav-header">个人资料</li>
						<li class="divider"></li>
						<li >
							<a href="user">
								<i class="icon-user"></i>个人资料
							</a>
						</li>
						<li class="active">
							<a href="user?m=password">
								<i class="icon-white icon-qrcode"></i>修改密码
							</a>
						</li>
					</ul>
				</div>
			</div>
			<div class="span9">
                <form class="form-horizontal" action="user?m=password" method="post" id = "myform">
                    <fieldset>  
                        <legend>修改登录密码</legend>
                    	 <c:choose>
							<c:when test="${param.code == '10001' }">
								<div class="well">密码错误或服务器忙，修改失败！</div>
							</c:when>
							<c:when test="${param.code == '10002' }">
								<div class="well">修改成功！</div>
							</c:when>
						</c:choose>           
						<div class="control-group" id="oldpwddiv">
                            <label class="control-label" for="oldpwd">请输入旧密码</label>
                            <div class="controls">
                                <input type="password" class="input-xlarge" id="oldpwd" name="oldpwd">
								<span class="help-inline" id="span1"></span>
                            </div>
                        </div>
						<div class="control-group" id="newpwddiv">
                            <label class="control-label" for="newpwd">请输入新密码</label>
                            <div class="controls">
                                <input type="password" class="input-xlarge" id="newpwd" name="newpwd">
								<span class="help-inline" id="span2"></span>
                            </div>
                        </div>
						<div class="control-group" id="confirmpwddiv">
                            <label class="control-label" for="confirmpwd">请确认新密码</label>
                            <div class="controls">
                                <input type="password" class="input-xlarge" id="confirmpwd" name="confirmpwd">
								<span class="help-inline" id="span3"></span>
                            </div>
                        </div>
                        <div class="form-actions">
                            <button class="btn btn-primary" type="button" id="btn">修改</button>
                            <a href="main" class="btn">返回</a>
                        </div>
                    </fieldset>
                </form>
            </div>
        </div>
    </div>
	<script type="text/javascript">
		$(document).ready(function(){
			
			$("#oldpwd").focus(function(){
				$("#span1").html("");
				$("#oldpwddiv").removeClass("error");
			});
			$("#oldpwd").blur(function(){
				var oldpwd = $(this).val();
				if (oldpwd == "") {
					$("#span1").html("旧密码不能为空");
					$("#oldpwddiv").addClass("error");
				}
			});
			$("#newpwd").focus(function(){
				$("#span2").html("");
				$("#span3").html("");
				$("#newpwddiv").removeClass("error");
				$("#confirmpwddiv").removeClass("error");
				$("#confirmpwd").val("");
			});
			$("#newpwd").blur(function(){
				var pwd = $(this).val();
				if (pwd == "") {
					$("#span2").html("请输入新密码");
					$("#newpwddiv").addClass("error");
				}
			});	
			$("#confirmpwd").focus(function(){
				$("#span3").html("");
				$("#confirmpwddiv").removeClass("error");
			});
			$("#confirmpwd").blur(function(){
				var confirmpwd = $(this).val();
				var newpwd = $("#newpwd").val();
				if (confirmpwd == "") {
					$("#span3").html("请再次输入新密码");
					$("#confirmpwddiv").addClass("error");
				}
				if (confirmpwd != newpwd) {
					$("#span2").html("两次密码输入不一致");
					$("#newpwddiv").addClass("error");
				}
			});				
  			$("#btn").click(function(){
  				var oldpwd = $("#oldpwd").val();
  				var newpwd = $("#newpwd").val();
				var confirmpwd = $("#confirmpwd").val();
  				if (oldpwd == "") {
					$("#span1").html("旧密码不能为空");
					$("#oldpwddiv").addClass("error");
				}
  				if (newpwd == "") {
					$("#span2").html("请输入新密码");
					$("#newpwddiv").addClass("error");
				}
				if (confirmpwd == "") {
					$("#span3").html("请再次输入新密码");
					$("#confirmpwddiv").addClass("error");
				}
				if (confirmpwd != newpwd) {
					$("#span2").html("两次密码输入不一致");
					$("#newpwddiv").addClass("error");
				}
  				if (oldpwd != "" && newpwd != "" && confirmpwd != "" && confirmpwd == newpwd) {
					$("#myform").submit();
				}
  			});
  		});
	</script>
</body>
</html>